<template>
  <div class="pro-list">
    <!-- 滑动单元格 -->
    <van-swipe-cell :disabled="!isSlide">
      <div class="pro-info">
        <div class="pro-checkbox" v-if="isHasCheckbox">
          <van-checkbox
            v-model="proData.checked"
            checked-color="#0c34ba"
            @change="simpleSelect(proData.checked)"
          ></van-checkbox>
        </div>
        <div class="pro-img">
          <img class="auto-img" :src="proData.small_img" />
        </div>
        <div class="pro-box">
          <div class="pro-name">
            <div class="pro-item">
              <div class="pro-zhname">{{ proData.name }}</div>
              <div class="pro-rule">{{ proData.rule }}</div>
            </div>
            <div class="pro-enname">{{ proData.enname }}</div>
          </div>
          <div class="pro-price">
            <div class="p-price">&yen;{{ proData.price }}</div>
            <div class="p-count">
              <slot></slot>
            </div>
          </div>
        </div>
      </div>
      <template #right>
        <van-button @click="remove" square type="danger" text="删除" />
      </template>
    </van-swipe-cell>
  </div>
</template>

<script>
export default {
  name: "prolist",
  data(){
      return{
          checked:true
      }
  },
  props: {
    proData: {
      type: Object,
      //类型对象,需要return
      default() {
        return;
      },
    },
    //是否滑动单元格
    isSlide: {
      type: Boolean,
      default: false,
    },
    //是否显示复选框
    isHasCheckbox: {
      type: Boolean,
      default: true,
    },
  },
  created() {
    //  console.log("数据",this.proData);
  },
  methods: {
    //单选
    simpleSelect() {
      this.$emit("simpleSelect");
    },

    //删除商品
    remove(){
        this.$emit('remove')
    }
  },
};
</script>

<style lang="less" scoped>
.pro-list {
  padding: 10px;
  background-color: #fff;
}
/deep/.van-swipe-cell__right .van-button--danger {
  height: 100%;
}

.pro-price {
  display: flex;
  align-items: center;
}
.p-price {
  margin-right: auto;
  color: #0c34ba;
  font-size: 14px;
  font-weight: bold;
}
.p-count {
  margin-right: 10px;
}
.pro-item {
  display: flex;
  align-items: center;
}
.pro-zhname {
  font-size: 14px;
  margin-right: 10px;
}

.pro-rule {
  color: #999;
}
.pro-enname {
  color: #999;
}
.pro-info {
  display: flex;
  align-items: center;
}
.peo-checkbox {
  width: 20px;
  height: 20px;
  margin-right: 10px;
}
.pro-img {
  width: 70px;
  height: 70px;
//   background-color: red;
  margin-right: 10px;
  margin-left: 10px;
}
.pro-name,
.pro-price {
  height: 35px;
}
.pro-box {
  flex: 1;
}
</style>